package com.shiyingzi.product.controller;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.shiyingzi.common.PageableData;
import com.shiyingzi.common.ResponseData;
import com.shiyingzi.product.model.AppABasicInformation;
import com.shiyingzi.product.model.AppBOccupational;
import com.shiyingzi.product.model.AppCIncomeAndLiability;
import com.shiyingzi.product.model.AppDContactInformation;
import com.shiyingzi.product.model.AppEBorrowerInformation;
import com.shiyingzi.product.model.AppFHouseProperty;
import com.shiyingzi.product.model.AppGWorkInformation;
import com.shiyingzi.product.model.AppHPolicyInformation;
import com.shiyingzi.product.model.AppIImpPath;
import com.shiyingzi.product.service.AppABasicInformationService;
import com.shiyingzi.product.service.AppBOccupationalService;
import com.shiyingzi.security.model.User;

@RestController
@RequestMapping(value = "product")
public class AppABasicInformationController {
	@Resource(name = AppABasicInformationService.BEAN_ID)
	private AppABasicInformationService appABasicInformationService;
	
	@Resource(name = AppBOccupationalService.BEAN_ID)
	private AppBOccupationalService appBOccupationalService;
	
	@RequestMapping(value = "/insert", method = { RequestMethod.GET, RequestMethod.POST })
	public ResponseData inserAppABasicInformation(AppABasicInformation code,AppBOccupational code2
			,AppCIncomeAndLiability code3,@RequestParam(value="adci",required=false) ArrayList<AppDContactInformation> adci
			,AppEBorrowerInformation code5,AppFHouseProperty code6,AppGWorkInformation code7 
			,AppHPolicyInformation code8,@RequestParam(value="filea",required=false)ArrayList<AppIImpPath> filea
//			,@RequestParam("fileb")MultipartFile[] fileb,@RequestParam("filec")MultipartFile[] filec
			,@RequestParam(value="fileb",required=false)ArrayList<AppIImpPath> fileb,@RequestParam(value="filec",required=false)ArrayList<AppIImpPath> filec
			,@RequestParam(value="filed",required=false)ArrayList<AppIImpPath> filed,@RequestParam(value="filee",required=false)ArrayList<AppIImpPath> filee
			,@RequestParam(value="filef",required=false)ArrayList<AppIImpPath> filef,@RequestParam(value="fileg",required=false)ArrayList<AppIImpPath> fileg
			,@RequestParam(value="fileh",required=false)ArrayList<AppIImpPath> fileh,@RequestParam(value="filei",required=false)ArrayList<AppIImpPath> filei){
		return appABasicInformationService.addProduct(code,code2,code3,adci,code5,code6
				,code7,code8,filea,fileb,filec,filed,filee,filef,fileg,fileh,filei);
	}
	
	@RequestMapping(value = "/update", method = { RequestMethod.GET, RequestMethod.POST })
	public ResponseData updateAppABasicInformation(AppABasicInformation code,AppBOccupational code2
			,AppCIncomeAndLiability code3,@RequestParam(value="adci",required=false) ArrayList<AppDContactInformation> adci
			,AppEBorrowerInformation code5,AppFHouseProperty code6
			,AppGWorkInformation code7 ,AppHPolicyInformation code8){
		return appABasicInformationService.upProduct(code,code2,code3,adci,code5,code6
				,code7,code8);
	}
	
	@RequestMapping(value = "/query", method = { RequestMethod.GET, RequestMethod.POST })
	public PageableData<AppABasicInformation> doQuery(int page, int limit, String userName){
		return appABasicInformationService.queryAppABasicInformationList(page, limit, userName);
	}
	
	@RequestMapping(value = "/getProductById", method = { RequestMethod.GET, RequestMethod.POST })
	public AppABasicInformation getProductById(Integer id){
		return appABasicInformationService.getProductById(id);
	}
	
	@RequestMapping(value = "/updateStateById", method = { RequestMethod.GET, RequestMethod.POST })
	public ResponseData updateStateById(AppABasicInformation code){
		AppABasicInformation aab=appABasicInformationService.getProductById(code.getId());
		aab.setProgressiveState(code.getProgressiveState());
			aab.setRemarks(code.getRemarks());
		return appABasicInformationService.upAppABasicInformation(aab);
	}
}
